package com.person.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.catalina.connector.Response;

import com.person.daoImpl.AdminDaoImpl;
import com.person.vo.Article;
import com.person.vo.Comment;

/**
 * Servlet implementation class getCommetnsServlet
 */
//@WebServlet("/getCommetnsServlet")
public class getCommentsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public getCommentsServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html; charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		HttpSession session = request.getSession();
		Comment commtent = new Comment();
		session.setAttribute("history", commtent);
		
		Article arti = (Article)session.getAttribute("arti");
		
		AdminDaoImpl adi = new AdminDaoImpl();
		List<Comment> lists = null;
		lists = adi.queryParentListById(arti.getId());
		request.setAttribute("commList", lists);
		session.setAttribute("CommFlag", 1);
		System.out.println("getComments");
		request.getRequestDispatcher("/frontPages/article.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
